using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using ScreenTest.Players;

namespace ScreenTest.Items
{
    class BaseItem
    {
        protected Vector2 position;
        protected float respawnTime;
        protected bool isActive;
        protected int size;

        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        public BoundingBox GetBoundingBox()
        {
            Vector3 min, max;

            min = new Vector3(position.X - size / 2, position.Y - size / 2, 0);
            max = new Vector3(position.X + size / 2, position.Y + size / 2, 0);

            return new BoundingBox(min, max);
        }

        public virtual void Load(ContentManager content) { }

        public virtual void Draw(GraphicsDevice device, SpriteBatch spriteBatch) { }

        public virtual void Update(GameTime gameTime) 
        {
            if (!isActive)
            {
                respawnTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (respawnTime <= 0f)
                {
                    Respawn();
                }
            }
        }

        public virtual void Touches(Player player) { }

        public virtual void Respawn()
        {
            isActive = true;
        }
    }
}
